/*
 * Copyright 2020-2021 redragon.dongbin
 *
 * This file is part of redragon-erp/赤龙ERP.

 * redragon-erp/赤龙ERP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.

 * redragon-erp/赤龙ERP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with redragon-erp/赤龙ERP.  If not, see <https://www.gnu.org/licenses/>.
 */
package com.erp.masterdata.material.dao.model;

import com.erp.masterdata.common.model.BaseModel;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
@Data
@Entity
@Table(name="md_material", schema="erp")
@DynamicInsert(true)
@DynamicUpdate(true)
public class MdMaterial extends BaseModel implements java.io.Serializable {

    //serialVersionUID
    private static final long serialVersionUID = 1L;

    //Constructors
    public MdMaterial() {
    }
    
    //Fields
    
    //主键
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "material_id", unique = true, nullable = false)
    private Integer materialId;

    //物料编码
    @NotBlank(message="{code.NotBlank}")
    @Column(name = "material_code", unique = true, nullable = false, length = 45)
    private String materialCode;
    
    //物料名称
    @NotBlank(message="{name.NotBlank}")
    @Column(name = "material_name", unique = false, nullable = false, length = 45)
    private String materialName;

    //是物料或服务（MATERIAL、MATTER）
    @NotBlank(message="物料或服务必须选择")
    @Column(name = "material_type", unique = false, nullable = false, length = 45)
    private String materialType;
    

    //类别编码
    @NotBlank(message="物料类别不能为空")
    @Column(name = "category_code", unique = false, nullable = false, length = 45)
    private String categoryCode;
    
    //物料单位
    //@NotBlank(message="物料单位不能为空")
    @Column(name = "material_unit", unique = false, nullable = false, length = 45)
    private String materialUnit;
    
    //品牌
    @Column(name = "brand", unique = false, nullable = true, length = 225)
    private String brand;

    //效期（天数）
    @Column(name = "valid_day", unique = false, nullable = true)
    private Integer validDay;
    
    //规格
    //@NotBlank(message="规格不能为空")
    @Column(name = "standard", unique = false, nullable = false, length = 45)
    private String standard;

    //规格单位
    //@NotBlank(message="规格单位不能为空")
    @Column(name = "standard_unit", unique = false, nullable = false, length = 45)
    private String standardUnit;

    //供应商
    @Column(name = "supplier", unique = false, nullable = true, length = 100)
    private String supplier;

    //备注
    @Column(name = "remark", unique = false, nullable = true, length = 225)
    private String remark;

    //包装规格
    @Column(name = "pack_standard", unique = false, nullable = true, length = 45)
    private String packStandard;

    
    //物料bom属性（自制MAKE、采购PO、委外ENTRUST）
    @Column(name = "bom_property", unique = false, nullable = true, length = 45)
    private String bomProperty;

    //生产前置期（天数）
    @Column(name = "produce_pre_days", unique = false, nullable = true)
    private Integer producePreDays;
    
    //版本
    @Column(name = "version", unique = false, nullable = false)
    private Integer version;
    
    //状态
    @Column(name = "status", unique = false, nullable = false, length = 1)
    private String status;
    
    //审批状态（未提交UNSUBMIT、已提交SUBMIT、已审批APPROVE、已驳回REJECT）
    @Column(name = "approve_status", unique = false, nullable = false, length = 45)
    private String approveStatus;
    
    //组织机构
    @Column(name = "org_code", unique = false, nullable = false, length = 10)
    private String orgCode;

    //错误原因
    @Transient
    private String errSource;

    /*
     * 显示字段
     */
    @Transient
    private String categoryDesc;

}